import Vue from 'vue'
import Router, {RouterMount} from './hhyang-uni-simple-router/index.js';
Vue.use(Router)
import {setPath,getToken} from '../storage'
const whiteList = ['/pages/login/login']
//初始化
const router = new Router({
    routes:ROUTES //路由表
});

//全局路由前置守卫
router.beforeEach((to, from, next) => {
	const token = getToken()
	//没有登录
	if(whiteList.indexOf(to.path)<0&&!token){
		setPath(to.path)
		next('/pages/login/login')
	}
	// if(from.path === to.path){return}
	// console.log(from.path+'==>'+to.path+"===>topUserId"+JSON.stringify(from))
  next()
})
// 全局路由后置守卫
router.afterEach((to, from) => {
	
})
export default router;